package com.gc.business.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gc.common.utils.StringUtils;
import org.springframework.stereotype.Service;
import com.gc.business.mapper.IntegralGoodsMapper;
import com.gc.business.domain.IntegralGoods;
import com.gc.business.service.IIntegralGoodsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;

/**
 * 积分商品 服务层实现
 * 
 * @author liujinteng
 * @date 2021-01-04
 */
@Slf4j
@Service
public class IntegralGoodsServiceImpl extends ServiceImpl<IntegralGoodsMapper, IntegralGoods> implements IIntegralGoodsService {

    @Override
    public List<IntegralGoods> list(IntegralGoods integralGoods){
        LambdaQueryWrapper<IntegralGoods> wrapper = new LambdaQueryWrapper<>();
        if(integralGoods != null){
            if(StringUtils.isNotEmpty(integralGoods.getGoodsId())){
                wrapper.eq(IntegralGoods::getGoodsId, integralGoods.getGoodsId());
            }
            if(StringUtils.isNotEmpty(integralGoods.getCompanyId())){
                wrapper.eq(IntegralGoods::getCompanyId, integralGoods.getCompanyId());
            }
            if(StringUtils.isNotEmpty(integralGoods.getGoodsName())){
                wrapper.like(IntegralGoods::getGoodsName, integralGoods.getGoodsName());
            }
            if(StringUtils.isNotEmpty(integralGoods.getGoodsCover())){
                wrapper.eq(IntegralGoods::getGoodsCover, integralGoods.getGoodsCover());
            }
            if(StringUtils.isNotEmpty(integralGoods.getGoodsRolling())){
                wrapper.eq(IntegralGoods::getGoodsRolling, integralGoods.getGoodsRolling());
            }
            if(StringUtils.isNotEmpty(integralGoods.getInventory())){
                wrapper.eq(IntegralGoods::getInventory, integralGoods.getInventory());
            }
            if(StringUtils.isNotEmpty(integralGoods.getMarketPrice())){
                wrapper.eq(IntegralGoods::getMarketPrice, integralGoods.getMarketPrice());
            }
            if(StringUtils.isNotEmpty(integralGoods.getCostPrice())){
                wrapper.eq(IntegralGoods::getCostPrice, integralGoods.getCostPrice());
            }
            if(StringUtils.isNotEmpty(integralGoods.getExchangeScore())){
                wrapper.eq(IntegralGoods::getExchangeScore, integralGoods.getExchangeScore());
            }
            if(StringUtils.isNotEmpty(integralGoods.getSendType())){
                wrapper.eq(IntegralGoods::getSendType, integralGoods.getSendType());
            }
            if(StringUtils.isNotEmpty(integralGoods.getGoodsStatus())){
                wrapper.eq(IntegralGoods::getGoodsStatus, integralGoods.getGoodsStatus());
            }
            if(StringUtils.isNotEmpty(integralGoods.getGoodsDetails())){
                wrapper.like(IntegralGoods::getGoodsDetails, integralGoods.getGoodsDetails());
            }
            if(StringUtils.isNotEmpty(integralGoods.getGoodsSort())){
                wrapper.eq(IntegralGoods::getGoodsSort, integralGoods.getGoodsSort());
            }
            if(StringUtils.isNotEmpty(integralGoods.getCreateBy())){
                wrapper.like(IntegralGoods::getCreateBy, integralGoods.getCreateBy());
            }
            if(StringUtils.isNotEmpty(integralGoods.getCreateTime())){
                wrapper.eq(IntegralGoods::getCreateTime, integralGoods.getCreateTime());
            }
            if(StringUtils.isNotEmpty(integralGoods.getUpdateBy())){
                wrapper.like(IntegralGoods::getUpdateBy, integralGoods.getUpdateBy());
            }
            if(StringUtils.isNotEmpty(integralGoods.getUpdateTime())){
                wrapper.eq(IntegralGoods::getUpdateTime, integralGoods.getUpdateTime());
            }
            if(StringUtils.isNotEmpty(integralGoods.getRemark())){
                wrapper.eq(IntegralGoods::getRemark, integralGoods.getRemark());
            }
        }
        return baseMapper.selectList(wrapper);
    }

    /**
     * 根据公司ID查找商品
     *
     * @param companyId
     * @return
     */
    @Override
    public List<IntegralGoods> selectGoodsByCompanyId(Long companyId,String goodsName,String goodsStatus) {
        return baseMapper.selectGoodsByCompanyId(companyId,goodsName,goodsStatus);
    }
}
